package cn.samler.project.guestbook.util;

import cn.samler.project.guestbook.model.common.Page;

public class PageUtil {
    public static int getStartRow(int page, int offset) {
        if (page <= 0) {
            page = 1;
        }

        return (page - 1) * offset + 1;
    }

    public static int getEndRow(int page, int offset) {
        if (page <= 0) {
            page = 1;
        }

        return (page - 1) * offset + offset;
    }

    public static int getStartRow(Page page) {
        return getStartRow(page.getPage(), page.getOffset());
    }

    public static int getEndRow(Page page) {
        return getEndRow(page.getPage(), page.getOffset());
    }
}
